def is_prime(n):
    if n <= 1:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True

def num_from_words(words):
    num_dict = {'zero': '0', 'one': '1', 'two': '2', 'three': '3', 'four': '4', 'five': '5', 'six': '6', 'seven': '7', 'eight': '8', 'nine': '9'}
    num_str = ''.join([num_dict.get(word, '') for word in words])
    return num_str if num_str.isdigit() else None

def nearest_prime(num_str):
    if len(num_str) != 3:
        return "Wrong input"
    
    num = int(num_str)
    lower_num = num
    upper_num = num
    
    while not is_prime(lower_num) and not is_prime(upper_num):
        lower_num -= 1
        upper_num += 1
    
    if is_prime(lower_num):
        return lower_num
    elif is_prime(upper_num):
        return upper_num
    else:
        return "Wrong input"

input_text = input("Введите три слова на английском языке: ").strip().lower()
words = input_text.split()

num_str = num_from_words(words)
if num_str:
    print(nearest_prime(num_str))
else:
    print("Wrong input")
